<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(function(){
            var connectId=Date.now()
            var webSocket;
            $("#connectId").val(connectId)
            $("#open").click(function () {
                if(webSocket == null ){
                    webSocket = new WebSocket("ws://localhost:8080/project1/websocket/"+connectId)
                }
            })
            $("#close").click(function () {
                if(webSocket != null ){
                    webSocket.close()
                    webSocket = null
                }
            })
            $("#send").click(function () {
                webSocket.send(connectId+":Hello")
            })

        })

    </script>
</head>
<body>
    <input type="text" value="" id="connectId">
    <input type="button" value="连接" id="open">
    <input type="button" value="断开" id="close">
    <input type="button" value="发送" id="send">
</body>
</html>